package com.gjw.utils;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class Save {
    public static String saveFile(MultipartFile file, String pathName){
        String contentType = file.getContentType();
        String extension = contentType.split("/")[1];
        String fileName = UUID.randomUUID() + "." + extension;
        try {
            file.transferTo(new File(pathName+fileName));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return fileName;
    }



}
